import xadmin
from xadmin import views


from . import models


class OrderAdmin(object):
    """订单管理"""
    list_display = ['order_id', 'create_time', 'total_amount', 'pay_method', 'status']
    refresh_times = [3, 5]  # 支持多少秒刷新页面

    data_charts = {
        'order_amount': {'title':'订单金额', 'x-field': 'create_time', 'y-field': ('total_amount',),
                         'order': ('create_time',)},
        'order_count': {'title':'订单量', 'x-field': 'create_time', 'y-field': ('total_count',),
                         'order': ('create_time',)},
    }

xadmin.site.register(models.OrderInfo, OrderAdmin)